package com.azier.kapacitor.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.Setter;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 1 * @Author: luoj
 * 2 * @Date: 2019/8/23 11:46
 * 3
 */
@Getter
@Setter
public class Task {

    /**
     * 任务ID
     */
    private String id;

    /**
     * 创建时间
     */
    @Setter(value = AccessLevel.PRIVATE)
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSSXXX", timezone = "GMT+8")
    private Date created;
    /**
     * 最后启动时间
     */
    @Setter(value = AccessLevel.PRIVATE)
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSSXXX", timezone = "GMT+8")
    private Date lastEnabled;
    /**
     * 修改时间
     */
    @Setter(value = AccessLevel.PRIVATE)
    @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSSXXX", timezone = "GMT+8")
    private Date modified;

    /**
     * kapacitor地址
     */
    @Setter(value = AccessLevel.PRIVATE)
    private TaskLink link;

    /**
     * 任务类型 stream / batch
     */
    private Type type;

    private List<TaskDbrps> dbrps;

    private String script;

    @Setter(value = AccessLevel.PRIVATE)
    private String dot;

    private Status status;

    @Setter(value = AccessLevel.PRIVATE)
    private boolean executing;

    @Setter(value = AccessLevel.PRIVATE)
    private String error;

    @Setter(value = AccessLevel.PRIVATE)
    private Map<String, Object> stats;

    private Map<String, Var> vars;

    @Override
    public String toString() {
        return "Task{" +
            "id='" + id + '\'' +
            "\n created='" + created + '\'' +
            "\n lastEnabled='" + lastEnabled + '\'' +
            "\n modified='" + modified + '\'' +
            "\n link=" + link +
            "\n type='" + type.getName() + '\'' +
            "\n dbrps=" + dbrps +
            "\n script='" + script + '\'' +
            "\n dot='" + dot + '\'' +
            "\n status='" + status.getName() + '\'' +
            "\n executing=" + executing +
            "\n error='" + error + '\'' +
            "\n stats=" + stats +
            "\n vars=" + vars +
            '}';
    }
}


